<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://www.ccut.edu.cn/saturn" prefix="saturn"%>

<%@ include file="/extjs/include/all.jsp" %>

<html>
<head>
<title>Saturn Debug</title>
</head>
<script type="text/javascript">
	function openDebug(type,j){
		var url = "value.jsp?type="+type+"&index="+j;
		window.showModalDialog(url,window, "dialogHeight: 400px; dialogWidth: 880px; edge: Sunken; center: Yes; help: No; resizable: Yes; status: No;");
	}
</script>
<body>
<div id='component' style='width:100%'></div>
<div id="paraGrid"></div>
<div id="paraAfterGrid"></div>
<div id="logGrid"></div>
<%
String key = request.getParameter("key");
 %>
<script>
Ext.onReady(function(){

   var debugThread = new Ext.data.JsonStore({	
	    url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.debug.impl::/extDebugModule/action/DebugComponentDetail.action?name=<%=key%>',
		root: 'debugComponentInfo',
		
		fields:[
			{name:'name',mapping:'name'},
			{name:'key',mapping:'key'},
			{name:'startTimeStr',mapping:'startTimeStr'},
			{name:'endTimeStr',mapping:'endTimeStr'},
			{name:'runTime',mapping:'runTime'}
		]
	});	
	
	debugThread.load();
	
	var name;
	var key;
	var startTimeStr;
	var endTimeStr;
   	var runTime;
	
	debugThread.on('load', function(){
	    name = debugThread.getAt(0).get('name');
	    key = debugThread.getAt(0).get('key');
	    startTimeStr = debugThread.getAt(0).get('startTimeStr');
	    endTimeStr = debugThread.getAt(0).get('endTimeStr');
	    runTime = debugThread.getAt(0).get('runTime');
	    myPanel();	    
	});
	
	function myPanel(){
	var debugThread1 = new Ext.FormPanel({
		title:'Debug 组件明细',
		renderTo:'component',
		id:'debugThread1',
		frame:true,
		bodyStyle:'padding:5px,5px,0',
		items:[{
			layout:'form',
			items:[{
				layout:'column',
				items:[{
					columnWidth:.15,
					xtype:'label',
					text:'名称:'
				},{
					columnWidth:.8,
					xtype:'label',
					text: name
				}]
			},{
				layout:'column',
				items:[{
					columnWidth:.15,
					xtype:'label',
					text:'组件标识:'
				},{
					columnWidth:.8,
					xtype:'label',
					text: key
				}]
			},{
				layout:'column',
				items:[{
					columnWidth:.15,
					xtype:'label',
					text:'开始时间:'
				},{
					columnWidth:.8,
					xtype:'label',
					text: startTimeStr
				}]
			},{
				layout:'column',
				items:[{
					columnWidth:.15,
					xtype:'label',
					text:'结束时间:'
				},{
					columnWidth:.8,
					xtype:'label',
					text: endTimeStr
				}]
			},{
				layout:'column',
				items:[{
					columnWidth:.15,
					xtype:'label',
					text:'运行时间(秒):'
				},{
					columnWidth:.8,
					xtype:'label',
					text: runTime
				}]
			}]
		}]
	});
	}	
});
</script>

<script>

var parameterInfoStore;
var bodyWidth;

Ext.onReady(function(){
	bodyWidth = Ext.get('component').getWidth();
	parameterInfoStore = new Ext.data.JsonStore({	
	    url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.debug.impl::/extDebugModule/action/DebugParameterDetail.action?name=<%=key%>',
		root: 'debugParamBefore',
	
		fields:[
			{name:'name',mapping:'name'},
			{name:'simpleName',mapping:'simpleName'},
			{name:'scope',mapping:'scope'},
			{name:'passingType',mapping:'passingType'},
			{name:'valueKey',mapping:'valueKey'},
			{name:'value',mapping:'value'}
		]
	});
	
    parameterInfoStore.load();
    
	var cm = new Ext.grid.ColumnModel([ 
    	new Ext.grid.RowNumberer(),
        {header:'名称',dataIndex:'name',width:bodyWidth*.16},  
        {header:'类型',dataIndex:'simpleName',width:bodyWidth*.16}, 
        {header:'范围',dataIndex:'scope',width:bodyWidth*.16}, 
        {header:'输入输出',dataIndex:'passingType',width:bodyWidth*.16},
        {header:'key',dataIndex:'valueKey',width:bodyWidth*.16},
        {header:'值',dataIndex:'value',width:bodyWidth*.16}
    ]); 
    
	cm.defaultSortable = false; 
	
	var grid = new Ext.grid.GridPanel({ 
	    el: 'paraGrid', 
	    title:'执行前参数信息',
	    frame:true,
	    autoHeight:true,
	    stripeRows: true,
	    trackMouseOver:false,
		enableColumnHide:false,
		enableHdMenu:false,
		enableColumnMove:false,
	    bodyStyle:'width:100%',
	    loadMask: {msg:'正在加载数据，请稍侯……'}, 
	    store:parameterInfoStore, 
	    cm:cm,
	    tbar:[{
	    	xtype:'label',
            text:'上下文信息',
            tooltip:'上下文信息'
        }, '-',{
        	//xtype:'button',
            text:'显示内容',
            tooltip:'显示内容',
            //iconCls:'remove',
            handler : function(btn){        
            	window.open('value.jsp?context=debug_saturn_value_context','_blank');
            }
        }]
	}); 
    grid.render();
});
</script>


<script>

Ext.onReady(function(){

    var bodyWidth;
    var parameterAfterStore
    bodyWidth = Ext.get('component').getWidth();
        
	    parameterAfterStore = new Ext.data.JsonStore({	
	    url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.debug.impl::/extDebugModule/action/DebugParameterDetail.action?name=<%=key%>',
		root: 'debugParamAfter',
	
		fields:[
			{name:'name',mapping:'name'},
			{name:'simpleName',mapping:'simpleName'},
			{name:'scope',mapping:'scope'},
			{name:'passingType',mapping:'passingType'},
			{name:'valueKey',mapping:'valueKey'},
			{name:'value',mapping:'value'}
		]
	});

    parameterAfterStore.load();

	var paraAfterCm = new Ext.grid.ColumnModel([ 
    	new Ext.grid.RowNumberer(), 
        {header:'名称',dataIndex:'name',width:bodyWidth*.16},  
        {header:'类型',dataIndex:'simpleName',width:bodyWidth*.16}, 
        {header:'范围',dataIndex:'scope',width:bodyWidth*.16}, 
        {header:'输入输出',dataIndex:'passingType',width:bodyWidth*.16},
        {header:'key',dataIndex:'valueKey',width:bodyWidth*.16},
        {header:'值',dataIndex:'value',width:bodyWidth*.16}
    ]); 
    
	paraAfterCm.defaultSortable = false; 
	var paraAfterGrid = new Ext.grid.GridPanel({ 
	    el: 'paraAfterGrid', 
	    title:'执行后参数信息',
	    frame:true,
	    autoHeight:true,
	    stripeRows: true,
	    trackMouseOver:false,
		enableColumnHide:false,
		enableHdMenu:false,
		enableColumnMove:false,
	    bodyStyle:'width:100%',
	    loadMask: {msg:'正在加载数据，请稍侯……'}, 
	    store:parameterAfterStore, 
	    cm:paraAfterCm,
	    tbar:[{
	    	xtype:'label',
            text:'上下文信息',
            tooltip:'上下文信息'
        }, '-',{
            text:'显示内容',
            tooltip:'显示内容',
            handler : function(btn){        
            	window.open('value.jsp?context=debug_saturn_value_context','_blank');
            }
        }]
	}); 
    paraAfterGrid.render();
});
</script>

<script>
Ext.onReady(function(){
    var bodyWidth;
    bodyWidth = Ext.get('component').getWidth();
	var logStore = new Ext.data.JsonStore({	
	    url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.debug.impl::/extDebugModule/action/DebugLogDetail.action?name=<%=key%>',
		root: 'logList',
		
		fields:[
			{name:'key',mapping:'key'},
			{name:'level',mapping:'level'},
			{name:'message',mapping:'message'},
			{name:'exception',mapping:'exception'}
		]	
	});
	
	logStore.load();
	
	var cm = new Ext.grid.ColumnModel([ 
    	new Ext.grid.RowNumberer(),
        {header:'名称',dataIndex:'key',width:bodyWidth*.16},  
        {header:'级别',dataIndex:'level',width:bodyWidth*.16}, 
        {header:'信息',dataIndex:'message',width:bodyWidth*.48}, 
        {header:'异常',dataIndex:'exception',width:bodyWidth*.16}
    ]); 
    
	cm.defaultSortable = false; 
	var grid = new Ext.grid.GridPanel({ 
	    el: 'logGrid', 
	    title:'日志信息',
	    frame:true,
	    autoHeight:true,
	    stripeRows: true,
	    trackMouseOver:false,
		enableColumnHide:false,
		enableHdMenu:false,
		enableColumnMove:false,
	    bodyStyle:'width:100%',
	    loadMask: {msg:'正在加载数据，请稍侯……'}, 
	    store:logStore, 
	    cm:cm
	}); 
    grid.render();
});
</script>
</body>
</html>